class Solution {

    public int uniquePaths(int m, int n) {

        // int[m][n] = int[n-1][n]+int[m][n-1]
        int[] temp = new int[n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i == 0 || j == 0){
                    temp[j] = 1;
                }else{
                    temp[j] = temp[j-1]+temp[j];
                }
            }
        }
        return temp[temp.length-1];
    }

}
